package com.labichaoka.chaoka.ui.credit;

import com.labichaoka.chaoka.entity.LimitStatusResponse;

/**
 * Created by ruan on 2018/8/9.
 */

public class CalculatePresenterImpl implements CalculatePresenter,CalculateInteractor.OnCalculateFinishedListener {
    private CalculateInteractor interactor;
    private CalculateView view;

    public CalculatePresenterImpl(CalculateInteractor interactor, CalculateView view) {
        this.interactor = interactor;
        this.view = view;
    }

    @Override
    public void calculate() {
        if (view!=null){
            view.showProgress();
        }
        interactor.limitActStatus(this);
    }

    @Override
    public void onDestroy() {
    view = null;
    }

    @Override
    public void onCalculateSuccessed(LimitStatusResponse response) {
        view.hideProgress();
        view.setData(response);
    }

    @Override
    public void onCalculateFailed() {
        view.hideProgress();
    }
}
